import { createWebHistory, createRouter } from 'vue-router'

// 引入的页面
import Home from '../views/home/index.vue'
import HomeView from '../views/home/Home.vue'
import Login from '../views/home/Login.vue'
import Detail from '../views/Detail.vue'

// 路由表
const routes = [
  // 重定向
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    component: Home,
    // 二级路由
    children: [
      // 重定向
      {
        path: '/home',
        redirect: '/home/homes'
      },
      { 
        // 匹配的路劲
        path: 'homes', 
        // 展示的组件
        component: HomeView 
      },
      { 
        path: 'login', 
        component: Login 
      },
    ]
  },
  { 
    path: '/detail', 
    component: Detail 
  },
]

// 路由实例
export const router = createRouter({
  history: createWebHistory(),
  routes,
})